package ru.tulupov.factorialcalculator;

public class Main {
	public static void main(String[] args) {
		Parser parser = new Parser(System.in);

		System.out.println("Factorial calculator.");
		System.out.println("Please enter a number:");

		while (true) {
			try {
				int n = parser.parse();
				Factorial factorial = new Factorial(n);
				System.out.println(String.format("%d! = %d", n,
						factorial.getValue()));
				break;
			} catch (ParseException e) {
				System.err.println("Wrong input!");
			} catch (EOFParseException e) {
				System.exit(0);
			} catch (InvalidParameterException e) {
				System.err.println("Invalid parameter!");
			}
		}
	}
}
